package com.asj.house.controller;

import com.asj.house.client.HouseIntermediaryClient;
import com.asj.house.client.HouseRoomIntermediaryClient;
import com.asj.house.domain.HouseIntermediary;
import com.asj.house.returns.RespCode;
import com.asj.house.returns.RespEntity;
import com.asj.house.returns.RespTable;
import com.asj.house.utils.OSSUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * <p>
 * 中介信息配置 前端控制器
 * </p>
 *
 * @author asj
 * @since 2021-03-25
 */
@RestController
@RequestMapping("/house-room-intermediary")
@Slf4j
@Api(value = "中介房源相关接口", tags = "中介房源相关接口")
public class HouseRoomIntermediaryController {

    @Resource
    private HouseRoomIntermediaryClient houseRoomIntermediaryClient;

    @GetMapping("/checkBox")
    @ApiOperation(value = "房源分配中介复选框格式")
    @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "roomId", value = "房源id", required = true)
    public RespEntity listCheckBox(@RequestParam("roomId") Integer roomId) {
        RespEntity respEntity = houseRoomIntermediaryClient.listCheckBox(roomId);
        return respEntity;
    }

    @PutMapping("/update")
    @ApiOperation(value = "分配房源")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "String", name = "ids", value = "中介ids, 逗号间隔", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "roomId", value = "房源id", required = true)
    })
    public RespEntity updateHouseRoomIntermediary(@RequestParam(value = "ids", required = true) String ids,
                                                  @RequestParam(value = "roomId", required = true) Integer id) {
        RespEntity respEntity = houseRoomIntermediaryClient.updateIntermediary(ids, id);
        return respEntity;
    }

    @GetMapping("/tree")
    @ApiOperation(value = "中介房源信息树形展示")
    public RespEntity listTree() {
        RespEntity respEntity = houseRoomIntermediaryClient.listTree();
        return respEntity;
    }


}
